<template>
  <div>
    <el-form ref="optForm" :model="form" class="el-dialog__body" label-width="100px">
      <div class="ledgerTitle">项目信息</div>
      <el-row>
        <el-col :span="6">
          <el-form-item label-width="140px" label="项目信息: " prop="projectName" >
            {{form.projectName}}
          </el-form-item>
        </el-col>
      </el-row>
      <div class="ledgerTitle">基本信息</div>
      <div style="margin: 0 auto; width: 945px;">
        <el-row style="font-size: 15px; line-height: 2.6;">
          {{ form.auditedCompanyName }}:<br/>
          &ensp;&ensp;&ensp;&ensp;{{form.content}}
        </el-row>
        <el-row>
          <el-col style="display: flex; justify-content: flex-end;">
            审计处
          </el-col>
        </el-row>
        <el-row>
          <el-col style="display: flex; justify-content: flex-end;">
            {{form.createDate}}
          </el-col>
        </el-row>
      </div>
      <div class="ledgerTitle">整改通知书</div>
      <el-row>
        <el-col>
          <el-form-item label-width="140px" label="整改通知书:">
            <web-document :form-data="form" :readWord="'view'" :pageType="'rectifyNotice'"/>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>

import {mapGetters} from "vuex";
import {getNotice} from "@/api/adis/track/rectify";
import WebDocument from "@/components/form/webDocument.vue";

export default {
  name: 'RectifyView',
  props: {
    id: {
      type: String,
      default: ''
    },
    params: {
      type: Object,
    },
    isAudit: {
      type: Boolean,
      default: false,
    }
  },
  computed:{
    ...mapGetters(["permissions"])
  },
  components: {WebDocument},
  // dictTypes: ['audit_type'],
  data() {
    return {
      form: {},
    }
  },
  watch: {
    id: {
      handler(val) {
        if (val) {
          getNotice(this.id).then((res) => {
            if (res.data.data !== null){
              this.handleNoticeResponse(res.data.data)
              this.$emit('data-loaded', true);
            } else {
              this.$emit('data-loaded', false);
            }
          }).catch(() => {
            this.$emit('data-loaded', false);
          });
        }
      },deep: true, immediate: true
    },
    params: {
      handler(val){
        if (val){
          this.handleNoticeResponse(val)
        }
      },deep: true, immediate: true
    },
  },
  methods: {
    handleNoticeResponse(val){
      this.form = val
      const dateObj = new Date(this.form.sendDate);
      this.form.createDate = `${dateObj.getFullYear()}年${dateObj.getMonth() + 1}月${dateObj.getDate()}日`
    },
    openWord() {
      if(!this.form.wordFile) {
        this.$message({
          type: "warning",
          message: "该项尚未上传相关文书!"
        });
        return;
      }
      // this.$router.push({path:'/webOffice', query: {url: this.form.wordFile}})
      const { href } = this.$router.resolve({
        path: '/webOffice',
        query: {
          url: this.form.wordFile,
          type: this.isAudit ? 'edit' : 'view',
        }
      });
      window.open(href, '_blank');
    }
  }
}
</script>
